<?php
namespace Home\Controller;

use Util\AccessController;

class CouponController extends AccessController {

    /*
     * 用户领取优惠劵
     */
    public function Share() {
        $LS = Service('Card', 'card_log');
        $save['USER_ID'] = passport_decrypt($_POST['token'], C('JM_KEY'));
        $save['CARD_ID'] = passport_decrypt($_POST['ID'], C('JM_KEY'));
        $CZdata = $LS->find($save);
        if ($CZdata) {
            //用户已经领过优惠劵
            $OK = -1;
        } else {
            $save['CREATE_IP'] = get_client_ip();
            $OK = $LS->Add($save);
        }
        $DATA['OK'] = $OK;
        $res = $this->ResData($DATA);
        $this->ajaxReturn($res, 'JSON');

    }

}